<!DOCTYPE html>
<html>
	<head>
		<title>SecretCuz Test</title>
		<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
		<!--
		<script type="text/javascript">
			var apiRoot = 'https://tinspham.appspot.com/_ah/api';
			var clientId = '360160739971.apps.googleusercontent.com';
			var apiKey = 'AIzaSyAdjHPT5Pb7Nu56WJ_nlrMGOAgUAtKjiPM';
			var scopes = 'https://www.googleapis.com/auth/userinfo.email';

			function init() {
				signin(true);
			}

			function signin(mode) {
				gapi.auth.authorize({
					client_id : clientId,
					scope : scopes,
					immediate : mode,
					response_type: 'token id_token'
				}, handleAuthResult);
			}

			function handleAuthResult(authResult) {
				if (authResult && !authResult.error) {
					// User is signed in, load api and call my Endpoint
					gapi.client.load('oauth2', 'v2', function() {
						gapi.client.oauth2.userinfo.get().execute(function(resp) {
							console.log(resp);
							if (!resp.code) {
								var token = gapi.auth.getToken();
								token.access_token = token.id_token;
								gapi.auth.setToken(token);
      							// User is signed in, call my Endpoint
      							gapi.client.load('bapi', 'v1', function() {
									gapi.client.bapi.blogPostEndpoint.listBlogPost().execute(function(resp) {
										console.log(resp);
									});
								}, apiRoot);
							}
						});
					});
				}
			}

			function auth() {
				signin(false);
			};
		</script>
		<script src="https://apis.google.com/js/client.js?onload=init"></script>
		-->
		<script src="js/jquery-1.9.1.min.js"></script>
		<script>
			$(function() {
				$.ajax({
					type: 'GET',
					url: '_ah/api/bapi/v1/blogpost',
					
					async: false
				}).done(function(msg){
					console.log(msg);
				}).fail(function(){
					alert('Failed');
				});
			});
		</script>
	</head>
	<body>
		<a href="#" onclick="auth();" id="signinButton">Sign in!</a>
	</body>
</html>